package com.gec.yhzh.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gec.yhzh.entity.AppointmentVaccine;
import com.gec.yhzh.entity.Department;
import com.gec.yhzh.entity.Vaccine;
import com.gec.yhzh.service.IAppointmentVaccineService;
import com.gec.yhzh.service.IDepartmentService;
import com.gec.yhzh.service.IVaccineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 疫苗 前端控制器
 * </p>
 *
 * @author jerry
 * @since 2025-03-10
 */
@CrossOrigin
@RestController
@RequestMapping("/vaccine")
public class VaccineController {
    @Autowired
    private IVaccineService vaccineService;
    //JSON解析工具
    ObjectMapper objectMapper = new ObjectMapper();
    @GetMapping("/query")
    public String  queryDoctors() throws JsonProcessingException {
        Map<String, Object> result = new HashMap<>();
        List<Vaccine>  vaccineList = vaccineService.listAll();
        if (vaccineList == null || vaccineList.isEmpty()) {
            result.put("flag",false );
            return objectMapper.writeValueAsString(result);
        }
        result.put("flag",true );
        result.put("list",vaccineList );
        return objectMapper.writeValueAsString(result);
    }
}
